package com.example.njupt.uis.reservation;

import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.njupt.R;
import com.example.njupt.base.fragment.BaseFragment;
import com.example.njupt.data.StickyData;
import com.example.njupt.helper.RecycleViewDivider;
import com.example.njupt.okhttp.retrofit.BaseResult;
import com.example.njupt.uis.reservation.adapter.SourceAdapter;
import com.example.njupt.views.sticky.StickyHeaderLayout;
import com.example.njupt.views.sticky.StickySection;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Author:      mwang
 * Create Date: Created in 2021/5/25 17:49
 * Update Date:
 * Modified By:
 * Description:
 */
public class ReservationFragment extends BaseFragment<ReservationPresenter> {

    @BindView(R.id.fl_source)
    RecyclerView flSource;
    @BindView(R.id.shl_source)
    StickyHeaderLayout shlSource;

    private List<StickySection> sourceEntities = new ArrayList<>();

    @Override
    public void onLazyLoad() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_reservation;
    }

    @Override
    protected void initView() {
        getToolbarHelper().setTitle("关注");
        getToolbarHelper().enableBack();
        initSource();
    }

    private void initSource() {
        sourceEntities.clear();
        sourceEntities = StickyData.getInstance().productStickySections();
        SourceAdapter adapter = new SourceAdapter(getContext(), sourceEntities);

        RecycleViewDivider divider = new RecycleViewDivider(
                getContext(), LinearLayoutManager.VERTICAL, 2, ContextCompat.getColor(getContext(), R.color.main_line));
        flSource.addItemDecoration(divider);
        flSource.setLayoutManager(new LinearLayoutManager(getContext()));
        flSource.setAdapter(adapter);
        shlSource.setSticky(true);
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected ReservationPresenter createPresenter() {
        return null;
    }

    @Override
    public void showError(String msg) {

    }

    @Override
    public void onErrorCode(BaseResult result) {

    }
}
